/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.opgea.appstreet.domain.entities;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Ramesh
 */
@Entity
@Table(name = "product")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Product.findAll", query = "SELECT p FROM Product p"),
    @NamedQuery(name = "Product.findById", query = "SELECT p FROM Product p WHERE p.id = :id"),
    @NamedQuery(name = "Product.findBySearchKey", query = "SELECT p FROM Product p WHERE p.searchKey = :searchKey"),
    @NamedQuery(name = "Product.findByShortDetails", query = "SELECT p FROM Product p WHERE p.shortDetails = :shortDetails"),
    @NamedQuery(name = "Product.findByUploadedDate", query = "SELECT p FROM Product p WHERE p.uploadedDate = :uploadedDate")})
public class Product implements Serializable {
    
    @Id
    @GeneratedValue
    private Long Id;
    private String shortDetails;
    @Temporal(TemporalType.TIMESTAMP)
    @Column(length=1000000)
    private Date uploadedDate;
    private String searchKey;
    @ManyToOne(cascade= CascadeType.ALL)
    private Company company;
    @ManyToOne(cascade= CascadeType.ALL)
    private Category category;
    @ManyToOne(cascade= CascadeType.ALL)
    private SubCategory subCategory;
    @ManyToOne(cascade= CascadeType.ALL)
    private Country country;
    @ManyToOne(cascade= CascadeType.ALL)
    private City city;

    public Product() {
    }

    public Long getId() {
        return Id;
    }

    public void setId(Long Id) {
        this.Id = Id;
    }

    public Category getCategory() {
        return category;
    }

    public void setCategory(Category category) {
        this.category = category;
    }

    public City getCity() {
        return city;
    }

    public void setCity(City city) {
        this.city = city;
    }

    public Company getCompany() {
        return company;
    }

    public void setCompany(Company company) {
        this.company = company;
    }

    public Country getCountry() {
        return country;
    }

    public void setCountry(Country country) {
        this.country = country;
    }

    public String getSearchKey() {
        return searchKey;
    }

    public void setSearchKey(String searchKey) {
        this.searchKey = searchKey;
    }

    public String getShortDetails() {
        return shortDetails;
    }

    public void setShortDetails(String shortDetails) {
        this.shortDetails = shortDetails;
    }

    public SubCategory getSubCategory() {
        return subCategory;
    }

    public void setSubCategory(SubCategory subCategory) {
        this.subCategory = subCategory;
    }

    public Date getUploadedDate() {
        return uploadedDate;
    }

    public void setUploadedDate(Date uploadedDate) {
        this.uploadedDate = uploadedDate;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final Product other = (Product) obj;
        if (this.Id != other.Id && (this.Id == null || !this.Id.equals(other.Id))) {
            return false;
        }
        return true;
    }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 67 * hash + (this.Id != null ? this.Id.hashCode() : 0);
        return hash;
    }

    @Override
    public String toString() {
        return "Product{" + "Id=" + Id + ", shortDetails=" + shortDetails + ", uploadedDate=" + uploadedDate + ", searchKey=" + searchKey + ", company=" + company + ", category=" + category + ", subCategory=" + subCategory + ", country=" + country + ", city=" + city + '}';
    }
    
    
}
